package com.yanqu.road.server.cmd.union;

import com.yanqu.road.server.pb.UnionPb;
import com.yanqu.road.entity.union.UnionNotice;
import com.yanqu.road.server.cmd.base.AbstractCommand;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.manger.union.UnionNoticeMgr;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.server.protocol.Protocol;
import com.yanqu.road.server.command.Cmd;

import java.util.List;

//@Cmd(code = Protocol.S_UNION_NOTICE_LIST, desc = "获取公告列表")
public class UnionNoticeListCmd extends AbstractCommand {

	private List<UnionNotice> unionNoticeList;

	@Override
	public boolean parseData(YanQuMessage packet) throws Exception {
		return true;
	}

	@Override
	public void execute(GamePlayer player, YanQuMessage packet) throws Exception {
		String unionUid = player.getUserInfo().getUnionUid();
		unionNoticeList = UnionNoticeMgr.getUnionNoticeList(unionUid);
	}

	@Override
	public void sendData(GamePlayer player) {
		player.sendPacket(Protocol.U_UNION_NOTICE_LIST, UnionPb.parseUnionNoticeListMsg(unionNoticeList));
	}

}
